<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Boost搜索引擎</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <style>
        :root {
            --primary: #4e6ef2;
            --primary-dark: #3a56c4;
            --secondary: #f8f9fa;
            --text: #333;
            --text-light: #666;
            --border: #e0e0e0;
            --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            --radius: 12px;
            --transition: all 0.3s ease;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
            color: var(--text);
            min-height: 100vh;
            padding: 20px;
            line-height: 1.6;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
        }

        /* 头部样式 */
        header {
            text-align: center;
            padding: 40px 20px;
            margin-bottom: 30px;
        }

        .logo {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 15px;
            margin-bottom: 15px;
        }

        .logo-icon {
            font-size: 2.8rem;
            color: var(--primary);
        }

        .logo-text {
            font-size: 2.5rem;
            font-weight: 700;
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);

            /* 关键优化部分 - 添加标准属性和兼容性写法 */
            background-clip: text;
            -webkit-background-clip: text;
            color: transparent;
            -webkit-text-fill-color: transparent;
        }



        .tagline {
            font-size: 1.2rem;
            color: var(--text-light);
            max-width: 600px;
            margin: 0 auto;
        }

        /* 搜索区域 */
        .search-area {
            background: white;
            padding: 30px;
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            margin: 0 auto 40px;
            max-width: 800px;
            position: relative;
        }

        .search-box {
            display: flex;
            gap: 15px;
            position: relative;
        }

        .search-input {
            flex: 1;
            padding: 16px 20px 16px 50px;
            border: 2px solid var(--border);
            border-radius: 50px;
            font-size: 1.1rem;
            color: var(--text);
            outline: none;
            transition: var(--transition);
            background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23666" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>') no-repeat 20px center;
            background-size: 20px;
        }

        .search-input:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(78, 110, 242, 0.2);
        }

        .search-button {
            background: var(--primary);
            color: white;
            border: none;
            border-radius: 50px;
            padding: 0 40px;
            font-size: 1.1rem;
            font-weight: 600;
            cursor: pointer;
            transition: var(--transition);
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        .search-button:hover {
            background: var(--primary-dark);
            transform: translateY(-2px);
        }

        /* 结果区域 */
        .result-area {
            background: white;
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            overflow: hidden;
        }

        .result-stats {
            padding: 20px;
            border-bottom: 1px solid var(--border);
            color: var(--text-light);
            font-size: 0.95rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .sort-options {
            display: flex;
            gap: 15px;
        }

        .sort-options select {
            padding: 5px 10px;
            border-radius: 4px;
            border: 1px solid var(--border);
            background: white;
            color: var(--text);
        }

        .result-items {
            padding: 20px;
        }

        .result-item {
            padding: 25px;
            border-bottom: 1px solid var(--border);
            transition: var(--transition);
        }

        .result-item:hover {
            background-color: #fafbff;
            transform: translateY(-3px);
        }

        .result-title {
            font-size: 1.4rem;
            font-weight: 600;
            margin-bottom: 8px;
            display: block;
            text-decoration: none;
            color: var(--primary);
        }

        .result-title:hover {
            text-decoration: underline;
        }

        .result-url {
            color: #0d652d;
            font-size: 0.95rem;
            margin-bottom: 12px;
            display: block;
            word-break: break-all;
        }

        .result-snippet {
            color: var(--text);
            line-height: 1.7;
            margin-bottom: 15px;
        }

        .result-meta {
            display: flex;
            gap: 20px;
            color: var(--text-light);
            font-size: 0.9rem;
        }

        .highlight {
            background-color: #fff9c4;
            padding: 0 3px;
            border-radius: 3px;
            font-weight: 500;
        }

        /* 加载状态 */
        .loader {
            display: none;
            text-align: center;
            padding: 50px;
        }

        .loader-spinner {
            border: 4px solid #f3f3f3;
            border-top: 4px solid var(--primary);
            border-radius: 50%;
            width: 40px;
            height: 40px;
            animation: spin 1s linear infinite;
            margin: 0 auto 15px;
        }

        @keyframes spin {
            0% {
                transform: rotate(0deg);
            }

            100% {
                transform: rotate(360deg);
            }
        }

        /* 空状态 */
        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: var(--text-light);
        }

        .empty-state h3 {
            font-size: 1.8rem;
            margin-bottom: 15px;
            color: var(--text);
        }

        .empty-state p {
            max-width: 500px;
            margin: 0 auto 20px;
        }

        .search-examples {
            display: flex;
            justify-content: center;
            gap: 15px;
            flex-wrap: wrap;
            margin-top: 20px;
        }

        .example-tag {
            background: #f0f4ff;
            color: var(--primary);
            padding: 8px 15px;
            border-radius: 50px;
            font-size: 0.9rem;
            cursor: pointer;
            transition: var(--transition);
        }

        .example-tag:hover {
            background: var(--primary);
            color: white;
        }

        /* 页脚 */
        footer {
            text-align: center;
            padding: 40px 0 20px;
            margin-top: 50px;
            color: var(--text-light);
            font-size: 0.9rem;
        }

        .footer-links {
            display: flex;
            justify-content: center;
            gap: 25px;
            margin-bottom: 15px;
        }

        .footer-links a {
            color: var(--text-light);
            text-decoration: none;
            transition: var(--transition);
        }

        .footer-links a:hover {
            color: var(--primary);
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .search-box {
                flex-direction: column;
            }

            .search-button {
                padding: 15px;
            }

            .logo-text {
                font-size: 2rem;
            }

            .result-stats {
                flex-direction: column;
                gap: 10px;
                align-items: flex-start;
            }

            .sort-options {
                width: 100%;
                justify-content: space-between;
            }
        }

        @media (max-width: 480px) {
            .search-area {
                padding: 20px;
            }

            .logo {
                flex-direction: column;
            }

            .result-item {
                padding: 20px 15px;
            }

            .result-meta {
                flex-direction: column;
                gap: 8px;
            }
        }
    </style>
</head>

<body>
    <div class="container">
        <header>
            <div class="logo">
                <i class="fas fa-rocket logo-icon"></i>
                <h1 class="logo-text">Boost搜索引擎</h1>
            </div>
            <p class="tagline">高效、精准的Boost库文档搜索工具</p>
        </header>

        <div class="search-area">
            <div class="search-box">
                <input type="text" class="search-input" id="search-input" placeholder="输入关键词搜索Boost文档..."
                    autocomplete="off">
                <button class="search-button" id="search-button">
                    <i class="fas fa-search"></i> 搜索
                </button>
            </div>
        </div>

        <div class="result-area">
            <div class="result-stats">
                <div class="stats-info">找到约 <span id="result-count">0</span> 条结果</div>
                <div class="sort-options">
                    <span>排序方式：</span>
                    <select id="sort-by">
                        <option value="relevance">相关性</option>
                        <option value="date">最新</option>
                    </select>
                </div>
            </div>

            <div class="loader">
                <div class="loader-spinner"></div>
                <p>正在搜索中...</p>
            </div>

            <div class="empty-state">
                <h3>欢迎使用Boost搜索引擎</h3>
                <p>输入关键词查找Boost库相关文档和资源</p>
                <div class="search-examples">
                    <div class="example-tag" data-query="shared_ptr">shared_ptr</div>
                    <div class="example-tag" data-query="filesystem">filesystem</div>
                    <div class="example-tag" data-query="asio">asio</div>
                    <div class="example-tag" data-query="thread">thread</div>
                </div>
            </div>

            <div class="result-items" id="results-container">
                <!-- 搜索结果将动态插入到这里 -->
            </div>
        </div>

        <footer>
            <div class="footer-links">
                <a href="#">关于我们</a>
                <a href="#">使用条款</a>
                <a href="#">隐私政策</a>
                <a href="#">帮助中心</a>
            </div>
            <p>Boost搜索引擎 © 2023 | 基于Boost库文档构建</p>
        </footer>
    </div>

    <script>
        $(document).ready(function () {
            // 搜索按钮点击事件
            $('#search-button').click(function () {
                performSearch();
            });

            // 回车键触发搜索
            $('#search-input').keypress(function (e) {
                if (e.which === 13) {
                    performSearch();
                }
            });

            // 示例标签点击事件
            $('.example-tag').click(function () {
                const query = $(this).data('query');
                $('#search-input').val(query);
                performSearch();
            });

            // 执行搜索
            function performSearch() {
                const query = $('#search-input').val().trim();
                if (!query) return;

                // 显示加载动画
                $('.empty-state').hide();
                $('.loader').show();
                $('#results-container').empty();

                // 发送搜索请求
                $.ajax({
                    type: "GET",
                    url: "/s?word=" + encodeURIComponent(query),
                    success: function (data) {
                        displayResults(data);
                    },
                    error: function () {
                        $('.loader').hide();
                        $('#results-container').html(
                            '<div class="empty-state">' +
                            '<h3>搜索出错</h3>' +
                            '<p>无法连接到服务器，请稍后再试</p>' +
                            '</div>'
                        );
                    }
                });
            }

            // 显示搜索结果
            function displayResults(results) {
                $('.loader').hide();

                if (!results || results.length === 0) {
                    $('#results-container').html(
                        '<div class="empty-state">' +
                        '<h3>未找到相关结果</h3>' +
                        '<p>请尝试其他关键词或更具体的搜索条件</p>' +
                        '</div>'
                    );
                    $('#result-count').text('0');
                    return;
                }

                // 更新结果统计
                $('#result-count').text(results.length);

                // 生成结果项
                results.forEach(function (item) {
                    const resultHtml = `
                        <div class="result-item">
                            <a href="${item.url}" class="result-title" target="_blank">
                                ${highlightKeywords(item.title, $('#search-input').val())}
                            </a>
                            <span class="result-url">${item.url}</span>
                            <p class="result-snippet">
                                ${highlightKeywords(item.desc, $('#search-input').val())}
                            </p>
                            <div class="result-meta">
                                <span>Boost ${item.version || '1.82.0'}</span>
                                <span>${item.date || '2023-06-15'}</span>
                                <span>${item.category || 'Library'}</span>
                            </div>
                        </div>
                    `;
                    $('#results-container').append(resultHtml);
                });
            }

            // 高亮关键词
            function highlightKeywords(text, query) {
                if (!query || !text) return text;

                const keywords = query.split(' ');
                let highlighted = text;

                keywords.forEach(function (keyword) {
                    if (keyword.trim()) {
                        const regex = new RegExp(`(${escapeRegExp(keyword.trim())})`, 'gi');
                        highlighted = highlighted.replace(regex, '<span class="highlight">$1</span>');
                    }
                });

                return highlighted;
            }

            // 转义正则特殊字符
            function escapeRegExp(string) {
                return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
            }
        });
    </script>
</body>

</html>